<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;
/*单车预约上课记录*/
class BikeOrderLog extends AdminBase{
	protected $beforeActionList = [
        'before_index'=>['only'=>'index'],
    ];
	function _initialize() {
		parent::_initialize();	
    }
	/*单车预约上课列表*/
	function index(){
		echo $this->fetch();
	}
	function ajax_index(){
		$this->ajax($this->_ajax_index());
	}

	///////////////////////////////////////////////////////////////////////////////////
	/**
	 * 权限菜单
	 **/
	function before_index(){
		$auth_group=sp_get_auth_menu_3("10041013");
		$this->assign("menus",$auth_group);
	}
	
	private function _ajax_index(){
		$query=array(
					 'card_no'=>array("field" =>"card_no","operator" =>"="),
					 );
		$draw=input("draw",0)+1;//请求时间		 
		$where_and=join(" and ",sp_get_param_sql(request()->isPost(),$query));
		$shop_id=sp_get_current_shop_id();
		if(!empty($shop_id)){
			$where_and.=" and shop_id=$shop_id";
		}
		if(input("status")==1){
			$total=db("OrderClass")->where($where_and)->fetchsql(FALSE)->count(1);
			$list=db("OrderClass")->order("id desc")->where($where_and)->limit($this->get_limit())->fetchsql(FALSE)->select();	
		}else{
			$total=db("OrderClassError")->where($where_and)->fetchsql(FALSE)->count(1);
			$list=db("OrderClassError")->order("id desc")->where($where_and)->limit($this->get_limit())->fetchsql(FALSE)->select();
		}
		return array('pageData'=>$list,'total'=>$total,"draw"=>$draw);
	}
	///////////////////////////////////////////////////////////////////////////////////
}